set(IMPLOT_HEADERS src/implot.h src/implot_internal.h)
set(IMPLOT_SRC     src/implot.cpp src/implot_items.cpp src/implot_demo.cpp) 

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/backends")
list(APPEND IMPLOT_HEADERS src/backends/implot_backend.h src/backends/implot_impl_opengl3.h)
list(APPEND IMPLOT_SRC src/backends/implot_backend.h src/backends/implot_impl_opengl3.cpp)
endif()

add_library(implot ${IMPLOT_HEADERS} ${IMPLOT_SRC})
target_link_libraries(implot PUBLIC imgui)
target_compile_definitions(implot PUBLIC IMPLOT_DEBUG IMPLOT_DLL_EXPORT IMPLOT_BACKEND_ENABLE_OPENGL3 IMGUI_IMPL_OPENGL_LOADER_GLAD)
set_property(TARGET implot PROPERTY CXX_STANDARD 17)
if(MSVC)
  target_compile_options(implot PRIVATE /W4 /WX /arch:AVX2 /fp:fast /permissive-) 
else()
  target_compile_options(implot PRIVATE -Wall -Wextra -pedantic -Werror -Ofast)
endif()

target_sources(implot PRIVATE  ${IMPLOT_SRC} ${IMPLOT_HEADERS})
target_include_directories(implot PUBLIC src)